Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thoroughly Shutdown The Stack On Non-Interactive Chip Command #38046

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hawkinsw
Copy link

When there is a non-interactive CHIP Command, be sure to completely shutdown the stack. In the case where the stack is not completely shutdown, it is impossible to run another CHIP Command from within the same address space.

Testing

WIP

When there is a non-interactive CHIP Command, be sure to completely
shutdown the stack. In the case where the stack is not completely
shutdown, it is impossible to run another CHIP Command from within the
same address space.
@hawkinsw
Copy link
Author

Thank you (again) for all the work that you are putting into making this SDK so complete. I think that I found an issue where the partial shutdown of the stack can cause a problem and hope that this fix is appropriate. If it is, I am more than happy to add testing. I just didn't want to spam you with additional changes unless this fix is on the right track.

Copy link

github-actions bot commented Mar 17, 2025

PR #38046: Size comparison from b2a86bd to 01a8990

Full report (75 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section b2a86bd 01a8990 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1098418 1098418 0 0.0
RAM 94866 94866 0 0.0
bl702 lighting-app bl702+eth FLASH 653332 653332 0 0.0
RAM 33533 33533 0 0.0
bl702+wifi FLASH 830604 830604 0 0.0
RAM 22257 22257 0 0.0
bl706+mfd+rpc+littlefs FLASH 1063062 1063062 0 0.0
RAM 32181 32181 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 893844 893844 0 0.0
RAM 26920 26920 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 976740 976740 0 0.0
RAM 24668 24668 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 818472 818472 0 0.0
RAM 120296 120296 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 827384 827384 0 0.0
RAM 125392 125392 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 774244 774244 0 0.0
RAM 113764 113764 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 758528 758528 0 0.0
RAM 113972 113972 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 541934 541934 0 0.0
RAM 205152 205152 0 0.0
lock CC3235SF_LAUNCHXL FLASH 576034 576034 0 0.0
RAM 205400 205400 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 660069 660069 0 0.0
RAM 75436 75436 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 679929 679929 0 0.0
RAM 78076 78076 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 679929 679929 0 0.0
RAM 78076 78076 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 636853 636853 0 0.0
RAM 70504 70504 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 620309 620309 0 0.0
RAM 71676 71676 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 639953 639953 0 0.0
RAM 74220 74220 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 639953 639953 0 0.0
RAM 74220 74220 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 639805 639805 0 0.0
RAM 74684 74684 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 659521 659521 0 0.0
RAM 77228 77228 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 659521 659521 0 0.0
RAM 77228 77228 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 616145 616145 0 0.0
RAM 68772 68772 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 636005 636005 0 0.0
RAM 71412 71412 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 636005 636005 0 0.0
RAM 71412 71412 0 0.0
efr32 lock-app BRD4187C FLASH 941040 941040 0 0.0
RAM 159944 159944 0 0.0
BRD4338a FLASH 734520 734520 0 0.0
RAM 234844 234844 0 0.0
window-app BRD4187C FLASH 1033408 1033408 0 0.0
RAM 128048 128048 0 0.0
esp32 all-clusters-app c3devkit DRAM 103376 103376 0 0.0
FLASH 1785220 1785220 0 0.0
IRAM 83846 83846 0 0.0
m5stack DRAM 121964 121964 0 0.0
FLASH 1751742 1751742 0 0.0
IRAM 117043 117043 0 0.0
linux air-purifier-app debug unknown 4752 4752 0 0.0
FLASH 2659329 2659329 0 0.0
RAM 112304 112304 0 0.0
all-clusters-app debug unknown 5584 5584 0 0.0
FLASH 6124422 6124422 0 0.0
RAM 517552 517552 0 0.0
all-clusters-minimal-app debug unknown 5456 5456 0 0.0
FLASH 5317372 5317372 0 0.0
RAM 222680 222680 0 0.0
bridge-app debug unknown 5472 5472 0 0.0
FLASH 4631156 4631156 0 0.0
RAM 201000 201000 0 0.0
camera-app debug unknown 5456 5456 0 0.0
FLASH 4693690 4693690 0 0.0
RAM 196448 196448 0 0.0
camera-controller debug unknown 5776 5776 0 0.0
FLASH 11345651 11345651 0 0.0
RAM 597312 597312 0 0.0
chip-tool debug unknown 6112 6112 0 0.0
FLASH 13365709 13366183 474 0.0
RAM 605952 605952 0 0.0
chip-tool-ipv6only arm64 unknown 22120 22128 8 0.0
FLASH 11551528 11551992 464 0.0
RAM 658632 658632 0 0.0
fabric-admin debug unknown 5800 5800 0 0.0
FLASH 11636901 11636901 0 0.0
RAM 605736 605736 0 0.0
fabric-bridge-app debug unknown 4720 4720 0 0.0
FLASH 4462112 4462112 0 0.0
RAM 188200 188200 0 0.0
fabric-sync debug unknown 4976 4976 0 0.0
FLASH 5579237 5579237 0 0.0
RAM 471968 471968 0 0.0
lighting-app debug+rpc+ui unknown 6192 6192 0 0.0
FLASH 5525761 5525761 0 0.0
RAM 205200 205200 0 0.0
lock-app debug unknown 5424 5424 0 0.0
FLASH 4697900 4697900 0 0.0
RAM 192360 192360 0 0.0
ota-provider-app debug unknown 4760 4760 0 0.0
FLASH 4320110 4320110 0 0.0
RAM 181016 181016 0 0.0
ota-requestor-app debug unknown 4712 4712 0 0.0
FLASH 4450466 4450466 0 0.0
RAM 185504 185504 0 0.0
shell debug unknown 4240 4240 0 0.0
FLASH 2957900 2957900 0 0.0
RAM 145680 145680 0 0.0
thermostat-no-ble arm64 unknown 9456 9456 0 0.0
FLASH 4146936 4146936 0 0.0
RAM 229848 229848 0 0.0
tv-app debug unknown 5752 5752 0 0.0
FLASH 5918085 5918085 0 0.0
RAM 595400 595400 0 0.0
tv-casting-app debug unknown 5320 5320 0 0.0
FLASH 11538413 11538413 0 0.0
RAM 721744 721744 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 916332 916332 0 0.0
RAM 167463 167463 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 909200 909200 0 0.0
RAM 145707 145707 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 852812 852812 0 0.0
RAM 141243 141243 0 0.0
nxp contact k32w0+release FLASH 588480 588480 0 0.0
RAM 71004 71004 0 0.0
mcxw71+release FLASH 603704 603704 0 0.0
RAM 63144 63144 0 0.0
light k32w0+release FLASH 614292 614292 0 0.0
RAM 70292 70292 0 0.0
k32w1+release FLASH 687888 687888 0 0.0
RAM 72056 72056 0 0.0
lock mcxw71+release FLASH 752664 752664 0 0.0
RAM 67556 67556 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1661836 1661836 0 0.0
RAM 212352 212352 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1565796 1565796 0 0.0
RAM 208560 208560 0 0.0
light cy8ckit_062s2_43012 FLASH 1442548 1442548 0 0.0
RAM 197320 197320 0 0.0
lock cy8ckit_062s2_43012 FLASH 1471444 1471444 0 0.0
RAM 224984 224984 0 0.0
qpg lighting-app qpg6105+debug FLASH 665084 665084 0 0.0
RAM 105180 105180 0 0.0
lock-app qpg6105+debug FLASH 623536 623536 0 0.0
RAM 99792 99792 0 0.0
stm32 light STM32WB5MM-DK FLASH 461056 461056 0 0.0
RAM 141496 141496 0 0.0
telink bridge-app tl7218x FLASH 665848 665848 0 0.0
RAM 90712 90712 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 623428 623428 0 0.0
RAM 31488 31488 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 762206 762206 0 0.0
RAM 40420 40420 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 755314 755314 0 0.0
RAM 97540 97540 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 682364 682364 0 0.0
RAM 52192 52192 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 710922 710922 0 0.0
RAM 73400 73400 0 0.0
light-switch-app-ota-shell-factory-data tl3218x_retention FLASH 703472 703472 0 0.0
RAM 37664 37664 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 603042 603042 0 0.0
RAM 138640 138640 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 790380 790380 0 0.0
RAM 96388 96388 0 0.0
tizen all-clusters-app arm unknown 5152 5152 0 0.0
FLASH 1783584 1783584 0 0.0
RAM 94320 94320 0 0.0
chip-tool-ubsan arm unknown 11560 11564 4 0.0
FLASH 19092918 19094222 1304 0.0
RAM 8355044 8355620 576 0.0

Copy link
Contributor

@andy31415 andy31415 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding "request for changes" until the testing section in the summary moves from "WIP".

@andy31415
Copy link
Contributor

Thank you (again) for all the work that you are putting into making this SDK so complete. I think that I found an issue where the partial shutdown of the stack can cause a problem and hope that this fix is appropriate. If it is, I am more than happy to add testing. I just didn't want to spam you with additional changes unless this fix is on the right track.

Ideally we would have some description of what fails before the PR and succeeds after. This can serve both as a description of the issue and the test that proves that the issue was fixed.

@hawkinsw
Copy link
Author

Thank you (again) for all the work that you are putting into making this SDK so complete. I think that I found an issue where the partial shutdown of the stack can cause a problem and hope that this fix is appropriate. If it is, I am more than happy to add testing. I just didn't want to spam you with additional changes unless this fix is on the right track.

Ideally we would have some description of what fails before the PR and succeeds after. This can serve both as a description of the issue and the test that proves that the issue was fixed.

Of course!

The "problem" is re-running any command implemented as a derive class from CHIPCommand. For example, if a user modified the code of main of chip-tool in way that the user's command was executed twice (in the same thread and process), the second time that MaybeSetupStack is called, assertions will fail when (re)initializing parts of the stack because they are not properly shutdown in the MaybeShutdownStack function. I know that use case is "silly", however, I have leveraged the code written for chip-tool so that I can use it as a library for invoking commands and would like to be able to run commands repeatedly in the same thread/process.

I will investigate a way to write a unit test to demonstrate this odd behavior. If, however, you have any suggestions or guidance (as an expert!) I would very much appreciate it!

Again, thank you for all the work that you are doing on Matter and the SDK!
Will

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants